package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Service
public class PermissonServiceImpl implements PermissionService{
    @Autowired
    private DtsPermissionMapper permissionMapper;

    @Override
    public Set<String> queryPermissonByRoleIds(Integer[] ids) {
        if (ids==null||ids.length==0){
            return new HashSet<>();
        }
        QueryWrapper<DtsPermission> queryWrapper=new QueryWrapper<>();
        queryWrapper.in("id",ids);
        queryWrapper.eq("deleted",false);
        List<DtsPermission> permissionList = permissionMapper.selectList(queryWrapper);

        Set<String> objects = new HashSet<>();
        if (permissionList!=null){
            for (DtsPermission permission:permissionList) {
                objects.add(permission.getPermission());
            }
        }
        return objects;
    }
}
